package com.cmc.cloud.cmclink.doc.controller.admin.si;

import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.vo.blnopaymentvo.BlnoPaymentCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.blnopaymentvo.BlnoPaymentPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.blnopaymentvo.BlnoPaymentRespVO;
import com.cmc.cloud.cmclink.doc.vo.blnopaymentvo.BlnoPaymentUpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.operatelog.core.annotations.OperateLog;
import com.cmes.framework.operatelog.core.enums.OperateTypeEnum;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;


import com.cmc.cloud.cmclink.doc.entity.BlnoPaymentDO;
import com.cmc.cloud.cmclink.doc.convert.BlnoPaymentConvert;
import com.cmc.cloud.cmclink.doc.service.si.BlnoPaymentService;


/**
 * 提单指定支付方式信息前端接口Controller
 *
 * @author codegen
 */
@Tag(name = "管理后台 - 提单指定支付方式信息")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "blno-payment")
public class BlnoPaymentController {

    @Resource
    private BlnoPaymentService blnoPaymentService;

    @Operation(summary = "创建提单指定支付方式信息")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/create")
    public CommonResult<Void> createBlnoPayment(@Valid @RequestBody BlnoPaymentCreateReqVO createReqVO) {
        blnoPaymentService.createBlnoPayment(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新提单指定支付方式信息")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/update")
    public CommonResult<Void> updateBlnoPayment(@Valid @RequestBody BlnoPaymentUpdateReqVO updateReqVO) {
        blnoPaymentService.updateBlnoPayment(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除提单指定支付方式信息")
    @OperateLog(type = OperateTypeEnum.DELETE)
    @PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Void> deleteBlnoPayment(@PathVariable("id") Long id) {
        blnoPaymentService.deleteBlnoPayment(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得提单指定支付方式信息")
    @OperateLog(type = OperateTypeEnum.DELETE)
    @GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<BlnoPaymentRespVO> getBlnoPayment(@PathVariable("id") Long id) {
        BlnoPaymentDO blnoPayment = blnoPaymentService.getBlnoPayment(id);
        return CommonResult.success(BlnoPaymentConvert.INSTANCE.convert(blnoPayment));
    }

    @Operation(summary = "获得提单指定支付方式信息列表")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    public CommonResult<List<BlnoPaymentRespVO>> getBlnoPaymentList(@RequestParam("ids") Collection<Long> ids) {
        List<BlnoPaymentDO> list = blnoPaymentService.getBlnoPaymentList(ids);
        return CommonResult.success(BlnoPaymentConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得提单指定支付方式信息分页")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/page")
    @UseResponsePropertyAdvice
    public CommonResult<PageResult<BlnoPaymentRespVO>> getBlnoPaymentPage(@Valid BlnoPaymentPageReqVO pageVO) {
        PageResult<BlnoPaymentDO> pageResult = blnoPaymentService.getBlnoPaymentPage(pageVO);
        List<BlnoPaymentRespVO> results = BlnoPaymentConvert.INSTANCE.convertList(pageResult.getList());
        return CommonResult.success(new PageResult<>(results, pageResult.getTotal()));
    }
}
